package com.amose.model4.service.impl;

import com.amose.model4.entity.Article;
import com.amose.model4.repository.ArticleRepository;
import com.amose.model4.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * @author yangpeng
 * @time 2020/3/24
 * @since 1.0.0
 */
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    ArticleRepository articleRepository;
    @Override
    public Page<Article> queryPage(int page,int size) {
        PageRequest pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "created"));
        Page<Article> list = articleRepository.findAll(pageable);
        return list;
    }
}
